/*
 * globals.h
 *
 * Created: 12.09.2011 18:30:07
 *  Author: halfmann
 */ 


#ifndef GLOBALS_H_
#define GLOBALS_H_

#include <avr/io.h>

#define DEBUG
#define LCD_PRESENT

#define MMC_Tristate_PORT PORTA
#define MMC_Tristate_DDR  DDRA
#define MMC_Tristate_PIN  PA5

#define LCD_Backlight_PORT PORTC
#define LCD_BACKLIGHT_DDR DDRC
#define LCD_BACKLIGHT_PIN PC6

#define CUBE_DIMENSION	8
#define CUBE_BYTES 64
#define MODES_COUNT 6

enum mode 
{
	AUTO = 1,
	RANDOM = 2,
	SINGLEANI = 3,
	PCCONT = 4,
	PCCONFIG = 5,
	POWEROFF = 6
}mode;

volatile uint8_t cubeData[CUBE_DIMENSION][CUBE_DIMENSION];
volatile uint8_t framebuffer[CUBE_DIMENSION][CUBE_DIMENSION];
volatile uint8_t serialBuffer[CUBE_DIMENSION][CUBE_DIMENSION]; //64 Bytes fuer den Cube vom uart
volatile uint8_t activeLayer;
volatile uint8_t sdInitTimeout;
volatile uint8_t sdCardPresent;

volatile uint8_t activeEffect;
uint8_t escape;
uint8_t breakAnimation;
//uint8_t pcContinousModePending;
//uint8_t pcContinousModeActive;
//uint8_t leavePcContionousMode;

void activateSDCardTristate(void);
void uartDataParser(void);
void pcContinousMode(void);
void lcd_clearAnimationName();
void lcd_clearMode();

#define LCD_BACKL_SWITCH_ON (LCD_Backlight_PORT |= (1<<LCD_BACKLIGHT_PIN))
#define LCD_BACKL_SWITCH_OFF (LCD_Backlight_PORT &= ~(1<<LCD_BACKLIGHT_PIN))

#endif /* GLOBALS_H_ */